# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
# Note: This project is basically dead, but it's still needed for some packages.
pkgname=ronn
_gemname=$pkgname-ng
pkgver=0.9.1
pkgrel=4
pkgdesc="Convert Markdown files to manpages"
url="https://github.com/apjanke/ronn-ng"
arch="noarch"
license="MIT"
depends="
	groff
	ruby
	ruby-kramdown
	ruby-mustache
	ruby-nokogiri
	"
checkdepends="
	ruby-rake
	ruby-test-unit
	"
subpackages="$pkgname-doc"
source="https://github.com/apjanke/$_gemname/archive/v$pkgver/$_gemname-$pkgver.tar.gz
	fix-ruby-3.1-compat.patch
	mustache-1.X.patch
	"
builddir="$srcdir/$_gemname-$pkgver"
# FIXME
#-<p>or when <var>WORD</var> has a <dot.> or <colon>.</colon></dot.></p>
#+<p>or when <var>WORD</var> has a <dot.> or <var>colon</var>.</dot.></p>
options="!check"

build() {
	gem build $_gemname.gemspec
}

check() {
	rake test
}

package() {
	local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"
	local geminstdir="$gemdir/gems/$_gemname-$pkgver"

	gem install --local \
		--install-dir "$gemdir" \
		--bindir "$pkgdir/usr/bin" \
		--ignore-dependencies \
		--no-document \
		--verbose \
		$_gemname

	install -D -m 644 "$geminstdir"/man/$pkgname.1 \
		"$pkgdir"/usr/share/man/man1/$pkgname.1
	install -D -m 644 "$geminstdir"/man/$pkgname-format.7 \
		"$pkgdir"/usr/share/man/man7/$pkgname-format.7

	# Remove unnecessary files and rubbish...
	cd "$gemdir"
	rm -r cache build_info doc extensions plugins
	cd "$geminstdir"
	rm -r test man Rakefile [A-Z][A-Z][A-Z]*
}

sha512sums="
03d6856598740ff670a500b182d0be84b584c98245e81b605de6c126b79680be48d2ed18d4cf28252c0a82883b4740ae58c584e977d3f0a9480082a9eb560a9a  ronn-ng-0.9.1.tar.gz
995ba17153208a57d09b2666d70e501735bf3576cb5938e3c6d76335e89fef688a500ad6a8901ae52730f27cd20d541e936f3a1aa4344125f4047aeea6c3792c  fix-ruby-3.1-compat.patch
4242708d1fb857bfd6c2d7f05ec9f51a0a1ab323aa9fef1a8dad13d5f54271e04acbf99cbf62a8784e4483041f4b72427d6ee9a4c260ba50068f64f0fece1757  mustache-1.X.patch
"
